/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AuthorizeMenuRequest {
  authPointsValue?: int32(name='AuthPointsValue', example='3'),
  dataPortalId?: string(name='DataPortalId', example='0d173abb53e84c8ca7495429163b****'),
  menuIds?: string(name='MenuIds', example='54kqgoa****,pg1n135****'),
  userGroupIds?: string(name='UserGroupIds', example='34fd141d-4598-4093-8c33-8e066dcb****,3d2c23d4-2b41-4af8-a1f5-f6390f32****'),
  userIds?: string(name='UserIds', example='204627493484****,121344444790****'),
}

model AuthorizeMenuResponseBody = {
  requestId?: string(name='RequestId', example='188F0B12-00EF-41B3-944A-FB7EF06C9F43'),
  result?: int32(name='Result', example='2'),
  success?: boolean(name='Success', example='true'),
}

model AuthorizeMenuResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AuthorizeMenuResponseBody(name='body'),
}

async function authorizeMenuWithOptions(request: AuthorizeMenuRequest, runtime: Util.RuntimeOptions): AuthorizeMenuResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.authPointsValue)) {
    query['AuthPointsValue'] = request.authPointsValue;
  }
  if (!Util.isUnset(request.dataPortalId)) {
    query['DataPortalId'] = request.dataPortalId;
  }
  if (!Util.isUnset(request.menuIds)) {
    query['MenuIds'] = request.menuIds;
  }
  if (!Util.isUnset(request.userGroupIds)) {
    query['UserGroupIds'] = request.userGroupIds;
  }
  if (!Util.isUnset(request.userIds)) {
    query['UserIds'] = request.userIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'AuthorizeMenu',
    version = '2020-08-08',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function authorizeMenu(request: AuthorizeMenuRequest): AuthorizeMenuResponse {
  var runtime = new Util.RuntimeOptions{};
  return authorizeMenuWithOptions(request, runtime);
}

model CancelAuthorizationMenuRequest {
  dataPortalId?: string(name='DataPortalId', example='0d173abb53e84c8ca7495429163b****'),
  menuIds?: string(name='MenuIds', example='54kqgoa****,pg1n135****'),
  userGroupIds?: string(name='UserGroupIds', example='34fd141d-4598-4093-8c33-8e066dcb****,3d2c23d4-2b41-4af8-a1f5-f6390f32****'),
  userIds?: string(name='UserIds', example='204627493484****,121344444790****'),
}

model CancelAuthorizationMenuResponseBody = {
  requestId?: string(name='RequestId', example='D8749D65-E80A-433C-AF1B-CE9C180FF3B4'),
  result?: int32(name='Result', example='2'),
  success?: boolean(name='Success', example='true'),
}

model CancelAuthorizationMenuResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CancelAuthorizationMenuResponseBody(name='body'),
}

async function cancelAuthorizationMenuWithOptions(request: CancelAuthorizationMenuRequest, runtime: Util.RuntimeOptions): CancelAuthorizationMenuResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dataPortalId)) {
    query['DataPortalId'] = request.dataPortalId;
  }
  if (!Util.isUnset(request.menuIds)) {
    query['MenuIds'] = request.menuIds;
  }
  if (!Util.isUnset(request.userGroupIds)) {
    query['UserGroupIds'] = request.userGroupIds;
  }
  if (!Util.isUnset(request.userIds)) {
    query['UserIds'] = request.userIds;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CancelAuthorizationMenu',
    version = '2020-08-08',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function cancelAuthorizationMenu(request: CancelAuthorizationMenuRequest): CancelAuthorizationMenuResponse {
  var runtime = new Util.RuntimeOptions{};
  return cancelAuthorizationMenuWithOptions(request, runtime);
}

model ChangeVisibilityModelRequest {
  dataPortalId?: string(name='DataPortalId', example='0d173abb53e84c8ca7495429163b****'),
  menuIds?: string(name='MenuIds', example='54kqgoa****,pg1n135****'),
  showOnlyWithAccess?: boolean(name='ShowOnlyWithAccess', example='true'),
}

model ChangeVisibilityModelResponseBody = {
  requestId?: string(name='RequestId', example='75912036-5527-4B7E-9265-B481D6651AC2'),
  result?: int32(name='Result', example='1'),
  success?: boolean(name='Success', example='true'),
}

model ChangeVisibilityModelResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ChangeVisibilityModelResponseBody(name='body'),
}

async function changeVisibilityModelWithOptions(request: ChangeVisibilityModelRequest, runtime: Util.RuntimeOptions): ChangeVisibilityModelResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dataPortalId)) {
    query['DataPortalId'] = request.dataPortalId;
  }
  if (!Util.isUnset(request.menuIds)) {
    query['MenuIds'] = request.menuIds;
  }
  if (!Util.isUnset(request.showOnlyWithAccess)) {
    query['ShowOnlyWithAccess'] = request.showOnlyWithAccess;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ChangeVisibilityModel',
    version = '2020-08-08',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function changeVisibilityModel(request: ChangeVisibilityModelRequest): ChangeVisibilityModelResponse {
  var runtime = new Util.RuntimeOptions{};
  return changeVisibilityModelWithOptions(request, runtime);
}

model ListPortalMenuAuthorizationRequest {
  dataPortalId?: string(name='DataPortalId', example='0d173abb53e84c8ca7495429163b****'),
}

model ListPortalMenuAuthorizationResponseBody = {
  requestId?: string(name='RequestId', example='D8749D65-E80A-433C-AF1B-CE9C180FF3B4'),
  result?: [ 
    {
      menuId?: string(name='MenuId', example='54kqgoa****'),
      receivers?: [ 
        {
          receiverId?: string(name='ReceiverId', example='121344444790****'),
          receiverType?: int32(name='ReceiverType', example='0'),
        }
      ](name='Receivers'),
      showOnlyWithAccess?: boolean(name='ShowOnlyWithAccess', example='true'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListPortalMenuAuthorizationResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListPortalMenuAuthorizationResponseBody(name='body'),
}

async function listPortalMenuAuthorizationWithOptions(request: ListPortalMenuAuthorizationRequest, runtime: Util.RuntimeOptions): ListPortalMenuAuthorizationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dataPortalId)) {
    query['DataPortalId'] = request.dataPortalId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPortalMenuAuthorization',
    version = '2020-08-08',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listPortalMenuAuthorization(request: ListPortalMenuAuthorizationRequest): ListPortalMenuAuthorizationResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPortalMenuAuthorizationWithOptions(request, runtime);
}

model ListPortalMenusRequest {
  dataPortalId?: string(name='DataPortalId', example='0d173abb53e84c8ca7495429163b****'),
  userId?: string(name='UserId', example='1234567***'),
}

model ListPortalMenusResponseBody = {
  requestId?: string(name='RequestId', example='75912036-5527-4B7E-9265-B481D6651AC2'),
  result?: string(name='Result'),
  success?: boolean(name='Success', example='true'),
}

model ListPortalMenusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListPortalMenusResponseBody(name='body'),
}

async function listPortalMenusWithOptions(request: ListPortalMenusRequest, runtime: Util.RuntimeOptions): ListPortalMenusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dataPortalId)) {
    query['DataPortalId'] = request.dataPortalId;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListPortalMenus',
    version = '2020-08-08',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listPortalMenus(request: ListPortalMenusRequest): ListPortalMenusResponse {
  var runtime = new Util.RuntimeOptions{};
  return listPortalMenusWithOptions(request, runtime);
}

